<!-- 云诺 https://app.witframe.com/market/list/index?uid=24 -->
<template>
	<view class="content">
		<u-navbar title="公告" :autoBack="true" ></u-navbar>
				
		<view class="notice-content" :style="'min-height:'+(systemHeight-80)+'px'">
			<yn-list :lists="noticeList" type="notice"></yn-list>
			<u-loadmore :status="status" />
		</view>
		<yn-tabbar currentTab='home'></yn-tabbar>
	</view>
</template>

<script>
	import API from '@/common/api.js';
	var app = getApp();
	export default {
		data() {
			return {
				baseinfo: [],
				minappinfo: [],
				noticeList: [],
				isLastPage: false,
				status: "loading",
				page: 1,
			}
		},
		onLoad() {
			this.baseinfo = uni.getStorageSync('baseinfo');
			this.minappinfo = uni.getStorageSync('minappinfo');
			
			this.getNotice({page: 1});
		
		},
		onReachBottom() {
			if (!this.isLastPage) {
				this.getNotice({
					page: this.page
				})
		
			}
		},
		onPullDownRefresh() {
			this.page = 1;
			this.isLastPage = true;
			this.status = "loading";
			this.noticeList = [];
			this.getNotice();
			uni.stopPullDownRefresh(); //停止刷新
		},
		methods: {
			getNotice: function(args) {
				API.getNotice(args).then(res => {
					if (res.data.data.length < 10 || res.data.data == [] || res.data.data == null) {
							this.isLastPage = true;
							this.status = "nomore";
						}
					
						let tmp = [];
						let arr = res.data.data;
						arr.forEach(function(i, index) {
							tmp[index] = i;
							if (i['tPhoto']) {
								tmp[index]['tPhoto'] = API.getApiUrl() + '/cos/img?key=' + i['tPhoto'];
							} else {
								tmp[index]['tPhoto'] = '/static/images/default.png';
							}
						})
					
						this.noticeList = this.noticeList.concat(tmp);
					
						this.page = this.page + 1;
						console.log(this.page);
						this.isLoading = false;
				})
				.catch(err => {
					console.log(err)
				})
					
			},
		}
	}
</script>

<style lang="scss" scoped>
	.notice-content {
		position: relative;
		color: #333;
		font-family:"Arial","Microsoft YaHei","黑体","宋体",SimSun,FangSong,SimHei,KaiTi,sans-serif;
		padding-top: 120rpx;
	}
</style>
